import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:yi_shop/utils/colors.dart';

class MyCustomPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint()
      ..strokeWidth = 1
      ..style = PaintingStyle.stroke
      ..isAntiAlias = true
      ..color = ColorsUtils.parseColorFromHexString(ColorsUtils.colorCccc);
    dottedLine(size, paint, canvas);
  }

  void dottedLine(Size size, Paint paint, Canvas canvas) {
    double width = 260;
    double s = 10;
    double len = 8;
    double max = s;
    while (max < size.height) {
      canvas.drawLine(Offset(width, max), Offset(width, max + len), paint);
      max += len + s;
    }
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return this != oldDelegate;
  }
}

class MyCircular extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint();
    paint.isAntiAlias = true;
    paint.style = PaintingStyle.stroke;
    paint.strokeWidth = 4;
    paint.color = ColorsUtils.parseColorFromHexString(ColorsUtils.colorFbb8);
    Offset c = Offset(size.width / 2, size.height / 2);
    canvas.drawCircle(c, size.width / 2, paint);

    paint.color = ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048);

    Rect rect = Offset.zero & size;
    canvas.drawArc(rect, pi * 0.9, 2 * pi * 0.23, false, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return this != oldDelegate;
  }
}